﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SlideImagesProperty.ascx.cs" Inherits="NLUNZ.UserControls.SlideImagesProperty" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!--this control will
1. retrieve slideimages from database and display the list in gridview
2. enable edit/delete/insert
3. always sort the list by OrderNumber-->
<script type="text/javascript">
    $(document).ready(function () {
        $('#insertSlideshowSection').hide();
        $('#activeSlideshowSection').show();
        $('#inactiveSlideshowSection').hide();
        $('#insertSlideShowTab').click(function () {
            $('#insertSlideshowSection').toggle('slow');
        });
        $('#activeSlideshowTab').click(function () {
            $('#activeSlideshowSection').toggle('slow');
        });
        $('#inactiveSlideshowTab').click(function () {
            $('#inactiveSlideshowSection').toggle('slow');
        });
    });

</script>
<div class="property-box">
        <div>
        <div class="tabheaderContainer">
            <div id="insertSlideShowTab" class="tablinnerContainer">
            <a href="#" class="plainText">Insert Slideshow</a>
            </div>
                <div class="tabrefreshContainer">
        <asp:ImageButton ID="ImageButton3" runat="server"  onclick="LinkButton1_Click" 
            ImageUrl="~/Admin/Contents/Images/refresh.fw.png" />
        
    </div>
        </div>
        <div id="insertSlideshowSection">
        <div id="insertSlideShow" runat="server" style="padding: 10px 20px">
            <table cellspacing="0" cellpadding="0">
                <tr class="insert_evenrow"><td class="field-title">图片名字</td><td class="field-text">
                    <asp:TextBox ID="txtImageName" runat="server" Width="225px"></asp:TextBox></td></tr>
                <tr class="insert_oddrow"><td class="field-title">图片标题</td><td class="field-text">
                    <asp:TextBox ID="txtImageTitle" runat="server" Width="225px"></asp:TextBox></td></tr>
                <tr class="insert_evenrow"><td class="field-title">图片简介</td><td class="field-text">
                    <asp:TextBox ID="txtImageDescription" runat="server" Width="225px"></asp:TextBox></td></tr>
                <tr class="insert_oddrow"><td class="field-title">链接地址</td><td class="field-text">
                    <asp:TextBox ID="txtImageHyperLink" runat="server" Width="225px"></asp:TextBox></td></tr>
                <tr class="insert_evenrow"><td class="field-title">上传图片</td><td class="field-text">
                     <telerik:RadUpload ID="RadUpload1" runat="server" 
            TargetFolder="~/Images/slideshow" OverwriteExistingFiles="False" 
                         AllowedFileExtensions=".jpg,.gif,.png,.bmp" MaxFileInputsCount="1" 
                         onfileexists="RadUpload1_FileExists">
        </telerik:RadUpload>    
        <telerik:RadProgressArea ID="RadProgressArea1" runat="server">                
        </telerik:RadProgressArea>
                                                       </td></tr>
                <tr><td colspan="2" style="text-align: center; padding: 10px;">
    <asp:Button runat="server" ID="btnSubmit" CssClass="RadUploadSubmit" Text="Submit" 
            onclick="btnSubmit_Click" />

                    </td></tr>
            </table>
            <div id="showUploadMessage" runat="server">
                <asp:Literal runat="server" ID="showMessage"></asp:Literal>
            </div>
        </div>
        </div>
    </div>
    
    <div>
        <div style="height: 20px;"></div>
    <div class="tabheaderContainer">
        <div id="activeSlideshowTab" class="tablinnerContainer">
       <a href="#" class="plainText">Active Slideshow Images</a></div>
    <div class="tabrefreshContainer">
        <asp:ImageButton ID="ImageButton1" runat="server"  onclick="LinkButton1_Click" 
            ImageUrl="~/Admin/Contents/Images/refresh.fw.png" />
        
    </div>
    </div>
    <div style="padding: 20px 0;" id="activeSlideshowSection">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="Id" DataSourceID="LinqDataSourceActiveSlideImagesEdit" 
        EnableModelValidation="True" AllowPaging="True" CellPadding="4" 
        ForeColor="#333333" GridLines="None" Width="100%">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowEditButton="True" ButtonType="Image" 
                EditImageUrl="~/Images/edit-icon.gif" EditText="" 
                CancelImageUrl="~/Admin/Contents/Images/cancel-icon.gif" 
                UpdateImageUrl="~/Admin/Contents/Images/Update-icon.gif" >
            <ItemStyle Width="60px" />
            </asp:CommandField>
            <asp:BoundField DataField="OrderNumber" HeaderText="Order" 
                SortExpression="OrderNumber" >
            <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:BoundField DataField="LinkUrl" HeaderText="LinkUrl" 
                SortExpression="LinkUrl" />
                <asp:TemplateField HeaderText="Image">
                    <ItemTemplate>
                        <img class="gridImage" src='<%= ResolveClientUrl("~/Images/slideshow/") %><%#Eval("ImageUrl") %>' alt='<%#Eval("Name") %>' width="100px" height="50px"></img>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:TemplateField>
            <asp:CheckBoxField DataField="IsActive" HeaderText="Show" 
                SortExpression="IsActive" />
                
            <asp:CommandField ShowDeleteButton="True" ButtonType="Image" 
                DeleteImageUrl="~/Images/delete-icon.gif" >
            <ItemStyle Width="50px" />
            </asp:CommandField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <EmptyDataTemplate>
            No Active Slideshow. Please Add in the insert form.
        </EmptyDataTemplate>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="40px" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    </div>
    <asp:LinqDataSource ID="LinqDataSourceActiveSlideImagesEdit" 
        ContextTypeName="NLUNZ.Business.NLUDBDataContext" TableName="SlideImages" runat="server" 
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" 
        OrderBy="IsActive, OrderNumber" Where="IsActive == @IsActive">
        <WhereParameters>
            <asp:Parameter DefaultValue="True" Name="IsActive" Type="Boolean" />
        </WhereParameters>
    </asp:LinqDataSource>
    </div>
    
    <div>
    <div class="tabheaderContainer">
        <div id="inactiveSlideshowTab" class="tablinnerContainer">
        <a href="#" class="plainText">InActive Slideshow Images</a></div>
    <div class="tabrefreshContainer">
        <asp:ImageButton ID="ImageButton2" runat="server"  onclick="LinkButton1_Click" 
            ImageUrl="~/Admin/Contents/Images/refresh.fw.png" />
        
    </div>
    </div>
    <div style="padding: 20px 0;" id="inactiveSlideshowSection">
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="Id" DataSourceID="LinqDataSourceInactiveSlideImagesEdit" 
        EnableModelValidation="True" AllowPaging="True" CellPadding="4" 
        ForeColor="#333333" GridLines="None" Width="100%">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowEditButton="True" ButtonType="Image" 
                EditImageUrl="~/Images/edit-icon.gif" 
                CancelImageUrl="~/Admin/Contents/Images/cancel-icon.gif" 
                UpdateImageUrl="~/Admin/Contents/Images/Update-icon.gif" >
            <ItemStyle Width="60px" />
            </asp:CommandField>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
            <asp:BoundField DataField="LinkUrl" HeaderText="LinkUrl" 
                SortExpression="LinkUrl" />
                <asp:TemplateField HeaderText="Image">
                    <ItemTemplate>
                        <img class="gridImage" src='<%= ResolveClientUrl("~/Images/slideshow/") %><%#Eval("ImageUrl") %>' alt='<%#Eval("Name") %>' width="100px" height="50px"></img>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:TemplateField>
            <asp:CheckBoxField DataField="IsActive" HeaderText="Show" 
                SortExpression="IsActive" />
                
            <asp:CommandField ShowDeleteButton="True" ButtonType="Image" 
                DeleteImageUrl="~/Images/delete-icon.gif" >
            <ItemStyle Width="50px" />
            </asp:CommandField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <EmptyDataTemplate>
            No Inactive Slideshow
        </EmptyDataTemplate>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="40px" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    </asp:GridView>
    </div>
    <asp:LinqDataSource ID="LinqDataSourceInactiveSlideImagesEdit" 
        ContextTypeName="NLUNZ.Business.NLUDBDataContext" TableName="SlideImages" runat="server" 
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" 
        OrderBy="CreateDate desc" Where="IsActive == @IsActive">
        <WhereParameters>
            <asp:Parameter DefaultValue="False" Name="IsActive" Type="Boolean" />
        </WhereParameters>
    </asp:LinqDataSource>
    </div>

</div>